package com.lagou.edu.controller;

import com.lagou.edu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author stevejson
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "/{orderId}/{orderName}", method = RequestMethod.POST)
    public Object createOrder(@PathVariable("orderId") Integer orderId, @PathVariable("orderName") String orderName){
        return orderService.createOrder(orderId, orderName);
    }


    @RequestMapping(value = "/{orderId}", method = RequestMethod.PUT)
    public Object payOrder(@PathVariable("orderId") Integer orderId){
        return orderService.payOrder(orderId);
    }

    @RequestMapping(value = "/active", method = RequestMethod.GET)
    public Object active(){
        return "active";
    }


}
